# -*- coding: utf-8 -*-
"""
Date: 2021-12-17
Author: J z
"""
from app.user.areaservice import action_register
from framework.firefly_dc.base_action import AuthLogAction


@action_register(action_id=20000)
class EnterMainInterface(AuthLogAction):
    """进入首页"""

    def parse_arguments(self):
        return self.get_str('RoleGuid')

    def take_action(self):
        res = self.cc.role.enter_main_interface(self.RoleGuid)
        self.add_response_dict(res)
        return True


@action_register(action_id=20002)
class GetRoleInfo(AuthLogAction):
    """获取角色信息"""

    def parse_arguments(self):
        return self.get_str('RoleGuid')

    def take_action(self):
        res = self.cc.role.get_role_info(self.RoleGuid)
        self.add_response_dict(res)
        return True


@action_register(action_id=20003)
class SendOrder(AuthLogAction):
    """发单"""

    def parse_arguments(self):
        return (self.get_str('RoleGuid') and
                self.get_int('GameId') and
                self.get_int('ServerType') and
                self.get_int('OrderType') and
                self.get_int('ServerId') and
                self.get_int('Price') and
                self.get_int('NeedTime') and
                self.get_int('SafePrice') and
                self.get_int('QuickPrice') and
                self.get_str('GameNickName') and
                self.get_str('GameDes') and
                self.get_str('GameAccount') and
                self.get_str('Mobile') and
                self.get_str('GamePassword') and
                self.get_str('Title')
                )

    def take_action(self):
        res = self.cc.role.order_send(self.RoleGuid, self.GameId, self.ServerType, self.ServerId, self.OrderType,
                                      self.Price, self.NeedTime, self.SafePrice, self.QuickPrice, self.GameAccount,
                                      self.GamePassword, self.Mobile, self.GameNickName, self.Title, self.GameDes)
        self.add_response_dict(res)
        return True


@action_register(action_id=20004)
class EnterOrderListInterface(AuthLogAction):
    """进入接单界面"""

    def parse_arguments(self):
        self.get_int('Page', default=1, mini=1)
        self.get_int('PageSize', default=20, mini=1)
        self.get_str('OrderColumn', default="")
        return True

    def take_action(self):
        res = self.cc.role.enter_order_list_interface(self.Page, self.PageSize, self.OrderColumn)
        self.add_response_dict(res)
        return True


@action_register(action_id=20005)
class RoleChooseSeat(AuthLogAction):
    """玩家抽取"""

    def parse_arguments(self):
        return self.get_str('RoleGuid')

    def take_action(self):
        res = self.cc.role.role_choose_seat(self.RoleGuid)
        self.add_response_dict(res)
        return True


@action_register(action_id=20006)
class CleanRole(AuthLogAction):
    """玩家结算"""

    def parse_arguments(self):
        return self.get_str('RoleGuid') and self.get_int('CostAmount')

    def take_action(self):
        res = self.cc.role.clean_role(self.RoleGuid, self.CostAmount)
        self.add_response_dict(res)
        return True


@action_register(action_id=20007)
class ServiceRoleCheckIn(AuthLogAction):
    """服务者签到"""

    def parse_arguments(self):
        return self.get_int('LockSeatId') and self.get_str('RoleGuid')

    def take_action(self):
        res = self.cc.role.service_role_check_in(self.RoleGuid, self.LockSeatId)
        self.add_response_dict(res)
        return True


@action_register(action_id=20008)
class CleanServiceRole(AuthLogAction):
    """服务者结算"""

    def parse_arguments(self):
        return self.get_str('RoleGuid')

    def take_action(self):
        res = self.cc.role.clean_service_role(self.RoleGuid)
        self.add_response_dict(res)
        return True


@action_register(action_id=20009)
class FilterServiceRoleAffairHistory(AuthLogAction):
    """
    查看历史匹配事件
    """

    def parse_arguments(self):
        self.get_int('Page', default=1, mini=1)
        self.get_int('PageSize', default=20, mini=1)
        return self.get_str('RoleGuid')

    def take_action(self):
        res = self.cc.role.filter_service_role_affair_history(self.RoleGuid, self.Page, self.PageSize)
        self.add_response_dict(res)
        return True


@action_register(action_id=20010)
class EnterPersonInfoInterface(AuthLogAction):
    """
    进入个人资料页
    """

    def parse_arguments(self):
        return self.get_str('RoleGuid')

    def take_action(self):
        res = self.cc.role.enter_person_info_interface(self.RoleGuid)
        self.add_response_dict(res)
        return True
